Skip to content

Show every task on the Tasks board, not just the first 100 - #446

Merged
abhishekgahlot2 merged 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/tasks-board-every-task
Nov 22, 2026
Merged

abhishekgahlot2 merged 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/tasks-board-every-task

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

By opening this pull request you agree to the Contributor License Agreement. On your first pull request a bot asks you to sign it with a one-line comment.

Fixes #294

GET /api/tasks stopped at 100 tasks in board order (column position, then newest first), and the board asked for all tasks in one request. A new task gets the highest position, so once a workspace had more than 100 tasks (archived ones included), the newest task disappeared after a reload and the column counts were short.

What changed

GET /api/tasks pages (backend/src/tasks/)

  • New query parameters: cursor and exclude_archived=1. The response now carries has_more and next_cursor next to tasks. limit is unchanged (default 100, held between 1 and 500).
  • Send next_cursor back as cursor, with the same other query, for the next page. Without a cursor the first page is the same as before, so the agent's tools and other callers see no change.
  • listTaskPageForOrg in repo.ts reads one page after the cursor, plus one row to know whether another page follows. listTasksForOrg, which the gateway's task_list tool uses, now sits on top of it with the same signature and result.
  • The cursor (page-cursor.ts) is the last task's full sort key: order_key, created_at as whole microseconds since the epoch, and id, as base64url JSON. Microseconds come from Postgres (extract(epoch …)) and go back as 'epoch' + n microseconds, the way the thread relationships cursor does it, so tasks created within one millisecond are neither repeated nor skipped.
  • order_key sorts up and the rest down, so "after the cursor" is order_key > k or (order_key = k and (created_at, id) < (c, i)).
  • A malformed cursor (bad base64 or JSON, wrong shape, a non-finite position, a bad microsecond count, a non-uuid id) answers 400 {"error":"cursor is invalid"} before any query. The query stays scoped to the caller's workspace.
  • exclude_archived=1 leaves archived tasks out in the query, so they never take a place on a page of the board.

The board (frontend/app/(library)/tasks/tasks-api.ts)

  • fetchTasks asks for pages of 500 with exclude_archived=1 and follows next_cursor to the end. The board and its column counts then hold every open task. Archived tasks have no column, and the board already dropped them.
  • A failed page fails the whole read, so the board shows its existing error state instead of part of the tasks.
  • A task moved while the pages are read can come back on a later page; it is shown once, where it was first read. A cursor answered twice stops the loop with an error.

Docs: the GET /api/tasks row in docs-site/docs/api/skills.mdx.

Across a release: an old board ignores the new fields. A new board talking to an old backend gets no next_cursor and reads one page, as it does today.

Tests

backend/src/tasks/repo.test.ts (the test in backend/src/tasks the issue asks for), against the real database:

  • 101 tasks: the first page of 100 is tasks 0 to 99 in board order, the newest task is alone on page two, and the next cursor is null there. listTasksForOrg still answers its first 100.
  • 12 tasks sharing one position and one exact creation instant, 3 more one microsecond apart, and a fractional position from a drag: pages of 1, 5 and 7 match the one-shot order exactly
  • 110 archived and 10 open tasks: the board page holds just the 10 open ones, and without the flag all 120 come back over two pages
  • another workspace's task never shows on a page

backend/src/tasks/page-cursor.test.ts: a round trip with fractional and negative positions, and 13 malformed cursors refused.

backend/test/tasks.test.ts, through the route:

  • 103 tasks with 2 archived: page one has 100 without the newest, has_more: true and a cursor; page two has the last 3 and has_more: false, next_cursor: null
  • with exclude_archived=1, the first page starts after the archived tasks, holds none, and the newest task comes on the next page
  • three invalid cursors answer 400

frontend/app/(library)/tasks/tasks-api.test.ts, over a stubbed fetcher: two pages read to the end (501 tasks) with the exact request paths, every page scoped to the chosen project, a missing cursor read as the last page, a 503 on page two failing the read, a task returned on two pages shown once, and a repeated cursor stopping the loop.

Checks with Bun 1.3.14, backend tests on pgvector/pgvector:0.8.6-pg16-bookworm:

  • bun run typecheck (root): passes
  • cd backend && bun run test: 3634 pass, 0 fail, then the Slack suite 119 pass, 0 fail
  • cd frontend && bun run test: 1985 pass, 0 fail
  • cd frontend && bun run lint: 248 warnings and 22 infos, the same as main
  • cd frontend && bun run build: passes
  • cd docs-site && bunx blume validate: no broken links
  • bun test scripts/agent-docs.test.ts: 5 pass

End to end

I ran a real backend on its own Postgres and a production build of the frontend (next start), signed in, and created tasks through POST /api/tasks: 3 archived first, then 104 spread over the three columns, then "Newest task". Open tasks: 57 to do, 28 in progress, 20 done.

  • The old read the board made, GET /api/tasks?scope=all, answers 100 tasks, 3 of them archived, without "Newest task" (and now says has_more: true).
  • /tasks in the browser shows Todo 57, In progress 28, Done 20, with "Newest task" on the board and no archived task. It is still there after a reload.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

GET /api/tasks returned at most 100 tasks in board order (column position,
then newest first), with no way to ask for more. New tasks get the highest
position, so once a workspace had more than 100 tasks, archived ones
included, a new task vanished from the board after a reload and the
column counts were short.

The list now pages, and the board reads every page:

- listTaskPageForOrg (backend/src/tasks/repo.ts) reads one page after a
  cursor that carries the last task's full sort key: order_key, created_at
  as whole microseconds, and id. order_key sorts up and the rest down, so
  "after the cursor" is a later position, or the same position and an
  older (created_at, id). It reads one row past the limit to know whether
  another page follows. listTasksForOrg, which the agent's task_list tool
  uses, keeps its shape on top of it.
- GET /api/tasks takes cursor and exclude_archived=1 and answers has_more
  and next_cursor next to tasks. A malformed cursor answers 400 "cursor is
  invalid" (backend/src/tasks/page-cursor.ts). Without a cursor the first
  page is the same as before.
- fetchTasks (frontend/app/(library)/tasks/tasks-api.ts) asks for pages of
  500 without archived tasks, which have no column, and follows
  next_cursor to the end. A failed page fails the read, so the board shows
  its error instead of part of the tasks. A task moved between two pages is
  shown once, and a repeated cursor stops the loop.

An old backend ignores the new parameters and sends no next_cursor, so the
new board reads one page as before. An old board ignores the new fields.

Docs: the GET /api/tasks row in docs-site/docs/api/skills.mdx.

@abhishekgahlot2 abhishekgahlot2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @officialasishkumar, this is a clean change: the cursor is strict with id as the last tiebreak, the after-cursor condition matches the sort, org scoping is tested, and replacing the whole list once per read avoids the boundary race #440/#443 had.

One thing before merging: fetchTasks (tasks-api.ts:28-40) follows next_cursor until it runs out, on every /tasks render and every project-filter change. Each page is capped at 500 but the total isn't, and nothing caps task creation (an agent looping task_create can get there). An org with 20,000 open tasks means 40 sequential requests and 20,000 cards in memory per board load; before this PR the board read at most 100.

Suggested fix: a named page ceiling far past any real board, with truncation reported instead of silent:

/** Board ceiling: 10 pages = 5,000 open tasks, far past any real board. */
const TASKS_MAX_PAGES = 10;
// before each fetch:
if (pages === TASKS_MAX_PAGES) return { tasks: [...tasks.values()], truncated: true };
pages += 1;

and have page.tsx / tasks-board.tsx read .tasks and show a "showing the first 5,000 open tasks" notice when truncated is set. With that, a 40-page stub stops at 10 calls. Load-more wouldn't fit here because the newest task sorts last.

Optional: a request-generation ref in refetch would stop a slow project-A read from landing under a project-B filter.

@abhishekgahlot2
abhishekgahlot2 merged commit 35a4e17 into useagenthq:main Nov 22, 2026
22 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026
@github-actions github-actions Bot unlocked this conversation Nov 22, 2026
@github-actions

Copy link
Copy Markdown

Thanks @officialasishkumar, merged. The Tasks board now shows every open task instead of stopping at 100.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show every task on the Tasks board, not just the first 100

2 participants